package com.opo5.logisticsmanagement.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.opo5.logisticsmanagement.common.R;
import com.opo5.logisticsmanagement.domain.VehicleList;
import com.opo5.logisticsmanagement.service.VehicleListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



@RestController
@CrossOrigin
@ResponseBody
@RequestMapping("tbsVehicles")
public class TbsVehicleListController {
    @Autowired(required = false)
    private VehicleListService vehicleListService;
    @GetMapping("/{currentPage}/{pageSize}")
    public R getAll(@PathVariable int currentPage,@PathVariable int pageSize,VehicleList vehicleList){
        IPage<VehicleList> page = vehicleListService.selectPage(currentPage,pageSize,vehicleList);
        return R.success(page);
    }

    /**
     *
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public R delList(@PathVariable int id){
        vehicleListService.removeById(id);
        return R.success("删除成功");
    }
    @PostMapping
    public R addList(@RequestBody VehicleList vehicleList){
        vehicleListService.save(vehicleList);
        return  R.success("增加成功");
    }
    @PutMapping
    public R updateList(@RequestBody VehicleList vehicleList){
        vehicleListService.updateById(vehicleList);
        return R.success("修改成功");
    }
}
